﻿using System;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.OleDb;

public partial class _classes : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form["Submit"] != null)
        {
            OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("App_Data/MainDB.mdb") + ";Persist Security Info=True");
            OleDbCommand mycomm = new OleDbCommand("INSERT INTO [Classes] (ClsChiName,ClsName,Clspic,ClsDataType,ClsValue,ClsValuePic,ClsIntro) VALUES ('" + Request.Form["ClsChiName"] + "', '" + Request.Form["ClsName"] + "', '" + Request.Form["ClsPic"] + "', " + (Request.Form["ClsDataType"]=="True") + ", '" + Request.Form["ClsValue"] + "', '" + Request.Form["ClsValuePic"] + "', '" + Request.Form["ClsIntro"] + "')", conn);
            conn.Open();
            mycomm.ExecuteNonQuery();
            mycomm = new OleDbCommand("ALTER TABLE [Species] ADD " + Request.Form["ClsName"] + ((Request.Form["ClsDataType"] == "True") ? " Text" : " Long"), conn);
            mycomm.ExecuteNonQuery();
            conn.Close();
            Response.Write("添加成功！");
        }
    }
}